<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
 <head>
  <meta http-equiv="content-type" content="text/html; charset=UTF-8">
  <title>Returns information about indexes on this collection</title>
<link media="all" rel="stylesheet" type="text/css" href="styles/03e73060321a0a848018724a6c83de7f-theme-base.css" />
<link media="all" rel="stylesheet" type="text/css" href="styles/03e73060321a0a848018724a6c83de7f-theme-medium.css" />

 </head>
 <body class="docs"><div class="navbar navbar-fixed-top">
  <div class="navbar-inner clearfix">
    <ul class="nav" style="width: 100%">
      <li style="float: left;"><a href="mongocollection.getdbref.html">« MongoCollection::getDBRef</a></li>
      <li style="float: right;"><a href="mongocollection.getname.html">MongoCollection::getName »</a></li>
    </ul>
  </div>
</div>
<div id="breadcrumbs" class="clearfix">
  <ul class="breadcrumbs-container">
    <li><a href="index.html">PHP Manual</a></li>
    <li><a href="class.mongocollection.html">MongoCollection</a></li>
    <li>Returns information about indexes on this collection</li>
  </ul>
</div>
<div id="layout">
  <div id="layout-content"><div id="mongocollection.getindexinfo" class="refentry">
 <div class="refnamediv">
  <h1 class="refname">MongoCollection::getIndexInfo</h1>
  <p class="verinfo">(PECL mongo &gt;=0.9.0)</p><p class="refpurpose"><span class="refname">MongoCollection::getIndexInfo</span> &mdash; <span class="dc-title">Returns information about indexes on this collection</span></p>

 </div>

 <div class="refsect1 description" id="refsect1-mongocollection.getindexinfo-description">
  <h3 class="title">Description</h3>
  <div class="methodsynopsis dc-description">
   <span class="modifier">public</span> <span class="methodname"><strong>MongoCollection::getIndexInfo</strong></span>(): <span class="type">array</span></div>

 </div>


 <div class="refsect1 parameters" id="refsect1-mongocollection.getindexinfo-parameters">
  <h3 class="title">Parameters</h3>
  <p class="para">This function has no parameters.</p>
 </div>


 <div class="refsect1 returnvalues" id="refsect1-mongocollection.getindexinfo-returnvalues">
  <h3 class="title">Return Values</h3>
  <p class="para">
   This function returns an array in which each element describes an index.
   Elements will contain the values <code class="literal">name</code> for the name of
   the index, <code class="literal">ns</code> for the namespace (a combination of the
   database and collection name), and <code class="literal">key</code> for a list of all
   fields in the index and their ordering. Additional values may be present for
   special indexes, such as <code class="literal">unique</code> or
   <code class="literal">sparse</code>.
  </p>
 </div>


 <div class="refsect1 examples" id="refsect1-mongocollection.getindexinfo-examples">
  <h3 class="title">Examples</h3>
  <div class="example" id="example-119">
   <p><strong>Example #1 <span class="function"><strong>MongoCollection::getIndexInfo()</strong></span> example</strong></p>
   <div class="example-contents">
<div class="phpcode"><code><span style="color: #000000">
<span style="color: #0000BB">&lt;?php<br /><br />$m&nbsp;</span><span style="color: #007700">=&nbsp;new&nbsp;</span><span style="color: #0000BB">MongoClient</span><span style="color: #007700">();<br /></span><span style="color: #0000BB">$c&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">$m</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">selectCollection</span><span style="color: #007700">(</span><span style="color: #DD0000">'test'</span><span style="color: #007700">,&nbsp;</span><span style="color: #DD0000">'venues'</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">var_dump</span><span style="color: #007700">(</span><span style="color: #0000BB">$c</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">getIndexInfo</span><span style="color: #007700">());<br /><br /></span><span style="color: #0000BB">?&gt;</span>
</span>
</code></div>
   </div>

    <div class="example-contents"><p>The above example will output
something similar to:</p></div>
   <div class="example-contents screen">
<div class="cdata"><pre>
array(4) {
  [0]=&gt;
  array(4) {
    [&quot;v&quot;]=&gt;
    int(1)
    [&quot;key&quot;]=&gt;
    array(1) {
      [&quot;_id&quot;]=&gt;
      int(1)
    }
    [&quot;name&quot;]=&gt;
    string(4) &quot;_id_&quot;
    [&quot;ns&quot;]=&gt;
    string(11) &quot;test.venues&quot;
  }
  [1]=&gt;
  array(4) {
    [&quot;v&quot;]=&gt;
    int(1)
    [&quot;key&quot;]=&gt;
    array(1) {
      [&quot;name&quot;]=&gt;
      float(1)
    }
    [&quot;name&quot;]=&gt;
    string(6) &quot;name_1&quot;
    [&quot;ns&quot;]=&gt;
    string(11) &quot;test.venues&quot;
  }
  [2]=&gt;
  array(4) {
    [&quot;v&quot;]=&gt;
    int(1)
    [&quot;key&quot;]=&gt;
    array(2) {
      [&quot;type&quot;]=&gt;
      float(1)
      [&quot;createdAt&quot;]=&gt;
      float(-1)
    }
    [&quot;name&quot;]=&gt;
    string(19) &quot;type_1_createdAt_-1&quot;
    [&quot;ns&quot;]=&gt;
    string(11) &quot;test.venues&quot;
  }
  [3]=&gt;
  array(5) {
    [&quot;v&quot;]=&gt;
    int(1)
    [&quot;key&quot;]=&gt;
    array(1) {
      [&quot;location&quot;]=&gt;
      string(8) &quot;2dsphere&quot;
    }
    [&quot;name&quot;]=&gt;
    string(17) &quot;location_2dsphere&quot;
    [&quot;ns&quot;]=&gt;
    string(11) &quot;test.venues&quot;
    [&quot;2dsphereIndexVersion&quot;]=&gt;
    int(2)
  }
}
</pre></div>
   </div>
  </div>
 </div>


 <div class="refsect1 seealso" id="refsect1-mongocollection.getindexinfo-seealso">
  <h3 class="title">See Also</h3>
  <p class="para">
   MongoDB core docs on 
   <a href="https://docs.mongodb.com/manual/indexes/" class="link external">&raquo;&nbsp;vanilla indexes</a> and
   <a href="https://docs.mongodb.com/manual/applications/geospatial-indexes/" class="link external">&raquo;&nbsp;geospatial indexes</a>.
  </p>
 </div>


</div></div></div></body></html>